//package com.yunhe.common.repository.base;
//
//import com.yunhe.common.domain.base.AlarmStatus;
//import org.springframework.data.neo4j.annotation.Query;
//import org.springframework.data.neo4j.repository.Neo4jRepository;
//import org.springframework.data.repository.query.Param;
//import org.springframework.stereotype.Repository;
//
//import java.util.List;
//import java.util.Map;
//
//@Repository
//public interface AlarmStatusRepository extends Neo4jRepository<AlarmStatus, Long> {
//
//    /**
//     * 根据代码获得告警状态对象
//     * @param code 代码
//     */
//    AlarmStatus findByCode(Long code);
//
//    /**
//     * 根据编号获得告警状态对象
//     * @param name 编号
//     */
//    AlarmStatus findByName(String name);
//
////    /**
////     * 根据代码绑定告警类型
////     * @param code 告警状态代码
////     * @param alarmTypeCode 告警类型代码
////     */
////    @Query("match(n:AlarmStatus),(m:AbnormalType) where n.code={code} " +
////            "and m.code={alarmTypeCode} create (n)-[:ALARMTYPE_OF]->(m)")
////    void bindAlarmTypeByCode(@Param("code") Long code, @Param("alarmTypeCode") Long alarmTypeCode);
////
////    /**
////     * 根据代码解绑告警类型
////     * @param code 告警状态代码
////     * @param alarmTypeCode 告警类型代码
////     */
////    @Query("match(m:AlarmStatus{code:{code}})-[r:ALARMTYPE_OF]->(n:AbnormalType{code:{alarmTypeCode}}) delete r")
////    void unbindAlarmTypeByCode(@Param("code") Long code, @Param("alarmTypeCode") Long alarmTypeCode);
////
////    /**
////     * 解绑所有的告警类型
////     * @param code 代码
////     */
////    @Query("match(a:AlarmStatus{code:{code}})-[r:ALARMTYPE_OF]->(p:AbnormalType) delete r")
////    void unbindAllAlarmTypeByCode(@Param("code") Long code);
//
//    /**
//     * 根据告警类型和告警位获取告警状态
//     * @param alarmTypeId 告警类型ID
//     * @param bit 告警位
//     */
//    @Query("start n=node({alarmTypeId}) match(n)-[:ALARMSTATUS_OF]->(a:AlarmStatus) where a.bit={bit} " +
//            "return ID(a) as id,a.code as code,a.name as name, a.title as title,a.sn as sn,a.bit as bit")
//    AlarmStatus findByTypeAndBit(@Param("alarmTypeId") Long alarmTypeId, @Param("bit") Integer bit);
//
//    /**
//     *
//     */
//    @Query("match(a:Analog)-[:POINTDATATYPE_OF]->(p:PointDataType) with p,a " +
//            "match(b:AbnormalType)-[:ALARMSTATUS_OF]->(c:AlarmStatus) where b.pointDataTypeCode=p.code return a.pointNumber")
//    Iterable<Long> findPointNumbers();
//
//
//    @Query("match (a:Analog)-[:POINTDATATYPE_OF]->(p:PointDataType) with p,a " +
//            "match (c:AlarmStatus)-[:ABNORMAL_TYPE_OF]->(b:AbnormalType) where b.pointDataTypeId=ID(p) " +
//            "return a.pointNumber as code,c.bit as bit,c.title as title")
//    Iterable<Map<String, Object>> findAlarmStatuses();
//
//    /**
//     * 获取告警格式
//     * @return
//     */
////    @Query("match(a:AlarmStatus{code:{code}})-[FORMAT_OF]->(f:AbnormalFormat) return f.content+':'+f.code as format limit 1")
//    @Query("match(a:AlarmStatus)-[:FORMAT_OF]->(f:AbnormalFormat) where ID(a)={id} return f.content limit 1")
//    String getFormat(@Param("id") Long id);
//
//    @Query("match(a:AlarmStatus)-[:HAS_ANALOG]->(b:Analog) where ID(a)={id} return b.pointNumber")
//    List<Long> getAlarmAnalog(@Param("id") Long id);
//
//    @Query("match(t:AbnormalType)-[]-(a:AlarmStatus) where ID(a)={id} return t.title limit 1")
//    String getTypeById(@Param("id") Long id);
//
//    @Query("match(t:AbnormalType)-[:ALARMSTATUS_OF]->(a:AlarmStatus) where ID(t)={id} return a limit 1")
//    AlarmStatus findByTypeId(@Param("id") Long typeID);
//
//    @Query("match(a:AlarmStatus)-[]-(b:AlarmLevel) where a.stationId={stationId} and (a.title=~'.*{queryStr}.*' or a.devTitle=~'.*{queryStr}.*' " +
//            "or a.condition=~'.*{queryStr}.*' or b.title=~'.*{queryStr}.*') return a order by {sort} skip {page}*{size} limit {page}")
//    Iterable<AlarmStatus> search(@Param("stationId") Long stationId,
//                                 @Param("page") int page,
//                                 @Param("size") int size,
//                                 @Param("sort") List<String> sort,
//                                 @Param("queryStr") String queryStr);
//
//    /**
//     * 批量更新告警级别
//     * @param alarmLevelId 告警级别ID
//     * @param idList 异常名称ID列表
//     */
//    @Query("match(a:AlarmStatus)-[r]->(b:AlarmLevel) where ID(a) in {idList} delete r with a match(c:AlarmLevel)" +
//            " where ID(c)={alarmLevelId} create(a)-[:ALARM_LEVEL_OF]->(c)")
//    void updateAlarmLevel(@Param("alarmLevelId") Long alarmLevelId, @Param("idList") List<Long> idList);
//}
